package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;

public class ExpandableLayout extends FrameLayout {
    private int ˊ = 300;
    private e ˋ;
    private boolean ˎ = false;
    private boolean ˏ = false;

    public static class b extends Animation {
        private int ˋ;
        private View ॱ;

        b(View view, int i) {
            this.ॱ = view;
            this.ˋ = i;
        }

        protected void applyTransformation(float f, Transformation transformation) {
            this.ॱ.getLayoutParams().height = f == 1.0f ? -1 : (int) (((float) this.ˋ) * f);
            this.ॱ.requestLayout();
        }

        public boolean willChangeBounds() {
            return true;
        }
    }

    public static class d extends Animation {
        private View ˎ;
        private int ˏ;

        d(View view, int i) {
            this.ˎ = view;
            this.ˏ = i;
        }

        protected void applyTransformation(float f, Transformation transformation) {
            if (f == 1.0f) {
                this.ˎ.setVisibility(8);
                return;
            }
            this.ˎ.getLayoutParams().height = this.ˏ - ((int) (((float) this.ˏ) * f));
            this.ˎ.requestLayout();
        }

        public boolean willChangeBounds() {
            return true;
        }
    }

    public interface e {
        void ˋ();
    }

    public ExpandableLayout(Context context) {
        super(context);
        ᐝ();
    }

    public ExpandableLayout(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        ᐝ();
    }

    public ExpandableLayout(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ᐝ();
    }

    private void ᐝ() {
        setTag("expandable");
    }

    public void setOnExpandStatusChangeListener(e eVar) {
        this.ˋ = eVar;
    }

    private void ˊ(boolean z) {
        this.ˏ = z;
    }

    public void ˏ() {
        if (!this.ˎ) {
            ˊ((View) this);
            this.ˎ = true;
            new Handler().postDelayed(new Runnable(this) {
                final /* synthetic */ ExpandableLayout ˊ;

                {
                    this.ˊ = r1;
                }

                public void run() {
                    this.ˊ.ˎ = false;
                }
            }, (long) this.ˊ);
        }
    }

    private void ˊ(View view) {
        ˊ(false);
        view.setLayerType(2, null);
        Animation dVar = new d(view, view.getMeasuredHeight());
        dVar.setDuration((long) this.ˊ);
        view.startAnimation(dVar);
        view.setLayerType(0, null);
    }

    public void ˊ() {
        if (!this.ˎ) {
            ˎ(this);
            this.ˎ = true;
            new Handler().postDelayed(new Runnable(this) {
                final /* synthetic */ ExpandableLayout ˋ;

                {
                    this.ˋ = r1;
                }

                public void run() {
                    this.ˋ.ˎ = false;
                }
            }, (long) this.ˊ);
        }
    }

    private void ˎ(View view) {
        ˊ(true);
        view.setLayerType(2, null);
        view.measure(-1, -2);
        int measuredHeight = view.getMeasuredHeight();
        view.getLayoutParams().height = 0;
        view.setVisibility(0);
        Animation bVar = new b(view, measuredHeight);
        bVar.setDuration((long) this.ˊ);
        view.startAnimation(bVar);
        view.setLayerType(0, null);
    }

    public void ˎ() {
        getLayoutParams().height = 0;
        invalidate();
        setVisibility(8);
        ˊ(false);
    }

    public void ˋ() {
        if (!ॱ()) {
            setVisibility(0);
            ˊ(true);
            getLayoutParams().height = -2;
            invalidate();
        }
        if (this.ˋ != null) {
            this.ˋ.ˋ();
        }
    }

    public boolean ॱ() {
        return this.ˏ;
    }
}
